<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="docgen-resources/docgen.css" type="text/css">
  <meta name="generator" content="FreeMarker Docgen (DocBook 5)">
  <title>
    FreeMarker Manual - Built-ins for booleans
  </title>
    <script type="text/javascript" src="docgen-resources/jquery.js"></script>
    <script type="text/javascript" src="docgen-resources/linktargetmarker.js"></script>
</head>
<body>

    <div class="navigation">
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_builtins.html">Built-in Reference</a>
            <b>></b>
          Built-ins for booleans
</span>    </div>
    <div class="bookmarks">
<span class="bookmarks">Bookmarks:
<a href="alphaidx.html">Alpha. index</a>, <a href="gloss.html">Glossary</a>, <a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a>, <a href="ref_builtins_alphaidx.html">?builtins</a>, <a href="ref_directive_alphaidx.html">#directives</a>, <a href="ref_specvar.html">.spec_vars</a>, <a href="app_faq.html">FAQ</a>, <a href="api/index.html">API</a>, <a href="../index.html">Home</a></span>    </div>
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_builtins_sequence.html"><span class="hideA">Next page: </span>Built-ins for sequences</a></div><div class="pagerButton"><a href="ref_builtins_date.html">Previous page</a></div><div class="pagerButton"><a href="ref_builtins.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    </div>

<div id="mainContent">

  
  
  
  
  <h1 class="rank_section1"
        id="pageTopTitle">
<a name="ref_builtins_boolean"></a>Built-ins for booleans  </h1>
    
    <div class="toc">
      <p>
        <b>
            Page Contents
        </b>
      </p>
      
  <ul class="noMargin">
      <li>
        <a href="#ref_builtin_c_boolean">c (when used with boolean)</a>
      </li>
      <li>
        <a href="#ref_builtin_string_for_boolean">string (when used with a boolean value)</a>
      </li>
  </ul>
    </div>
    <a name="docgen_afterTheTOC"></a>
    

            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_c_boolean"></a>c (when used with boolean)  </h2>


          

          

          

          

          <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <p class="rank_note">Note</p>

            <p>This built-in exists since FreeMarker 2.3.20.</p>
          </div>


          <p>This built-in converts a boolean to string for a
          "computer language" as opposed to for human audience.
          The result will be <tt style="color: #A03D10">&quot;true&quot;</tt> or
          <tt style="color: #A03D10">&quot;false&quot;</tt>, regardless of the
          <tt style="color: #A03D10">boolean_format</tt> setting. When generating
          JavaScript and such, this should be used, as otherwise changing the
          <tt style="color: #A03D10">boolean_format</tt> can break the generated
          computer-language output.</p>

          <p>Note that this built-in <a href="ref_builtins_number.html#ref_builtin_c">also
          works on strings</a>.</p>
        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="ref_builtin_string_for_boolean"></a>string (when used with a boolean value)  </h2>


          

          

          

          

          

          <p>Converts a boolean to a string. You can use it in two
          ways:</p>

              <div class="itemizedlist">
<ul>
            <li>
              <p>As <tt style="color: #A03D10">foo?string(&quot;yes&quot;, &quot;no&quot;)</tt>: This will
              return the first parameter (here: <tt style="color: #A03D10">&quot;yes&quot;</tt>) if
              the boolean is true, otherwise the second parameter (here:
              <tt style="color: #A03D10">&quot;no&quot;</tt>). Note that the return value is always a
              string; if the parameters were numbers, they would be converted
              to strings first.</p>
            </li>

            <li>
              <p><tt style="color: #A03D10">foo?string</tt>: <i>Deprecated
              starting from FreeMarker 2.3.20: use <a href="#ref_builtin_c_boolean"><tt>?c</tt></a>
              instead, or set the <tt style="color: #A03D10">boolean_format</tt> <a href="ref_directive_setting.html">setting</a> to something like
              <tt style="color: #A03D10">&quot;yes,no&quot;</tt> and then the conversion can happen
              automatically</i>. If you still need to know about this,
              this will convert the boolean to string using the default
              strings for representing true and false values. By default, true
              is rendered as <tt style="color: #A03D10">&quot;true&quot;</tt> and false is rendered
              as <tt style="color: #A03D10">&quot;false&quot;</tt>. This is mostly useful if you
              generate source code with FreeMarker <i>(but use
              <tt style="color: #A03D10">?c</tt> for that starting from 2.3.20)</i>,
              since the values are not locale (language, country) sensitive.
              To change these default strings, you can use the
              <tt style="color: #A03D10">boolean_format</tt> <a href="ref_directive_setting.html">setting</a>.</p>

              <p style="color:#333399; font-style:italic">Note, that in the very rare case
              when a value is multi-typed and is both a boolean and a string,
              then the string value of the variable will be returned, and so
              the <tt style="color: #A03D10">boolean_format</tt> setting will have no
              effect.</p>
            </li>
          </ul>    </div>

          
</div>

    <div class="navigation">
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_builtins_sequence.html"><span class="hideA">Next page: </span>Built-ins for sequences</a></div><div class="pagerButton"><a href="ref_builtins_date.html">Previous page</a></div><div class="pagerButton"><a href="ref_builtins.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_builtins.html">Built-in Reference</a>
            <b>></b>
          Built-ins for booleans
</span>    </div>
    </div>

<table border=0 cellspacing=0 cellpadding=0 width="100%">
    <tr>
      <td colspan=2><img src="docgen-resources/img/none.gif" width=1 height=8 alt=""></td>
    <tr>
      <td align="left" valign="top"><span class="smallFooter">
            FreeMarker Manual -- For FreeMarker 2.3.20
            <br>
          HTML generated: 2013-06-27 20:54:33 GMT
      </span></td>
      <td align="right" valign="top"><span class="smallFooter">
          <a href="http://www.xmlmind.com/xmleditor/">
            <img src="docgen-resources/img/xxe.gif" alt="Edited with XMLMind XML Editor">
          </a>
      </span></td>
    </tr>
</table>
  <!-- Put pre-loaded images here: -->
  <div style="display: none">
    <img src="docgen-resources/img/linktargetmarker.gif" alt="Here!" />
  </div>
</body>
</html>

